﻿using System;
using System.Collections.Generic;
using System.Text;
using MagicApp.Data.Enums;

namespace MagicApp.Data.Creature
{
    public  class Creature : Card
    {
        #region Members
        private IBlockingBehavior _blockingBehavior;
        private IAttackingBehavior _attackingBehavior;
        private ITappingBehavior _tappingBehavior;
        private bool hasFlight;
        private bool hasSummoningSickness;
        public bool HasFlight
        {
            get { return hasFlight; }
            set { hasFlight = value; }
        }
        public bool HasSummoningSickness
        {
            get { return hasSummoningSickness; }
            set { hasSummoningSickness = value; }
        }
        private int _power;
        public int Power { 
            get{ return _power;}
            set { this._power = value; } 
        }
        private int _toughness;
        public int Toughness
        {
            get { return _toughness; }
            set { this._toughness = value; }
        }

        #endregion

        #region .ctor
        public Creature(int cardID, string cardName, string cardDescription,
                    Series series, CardType cardType, CardColor color, CardRarity rarity,Image cardImage, CreatureType creatureType,
            bool hasFlight, bool hasSummoningSickness, int power, int toughness)
            : base(cardID, cardName, cardDescription, series, cardType, color, rarity,cardImage)
        {
            this.hasFlight = hasFlight;
            this.hasSummoningSickness = hasSummoningSickness;
            Power = power;
            Toughness = toughness;
        }
        public Creature(){}

        #endregion
        public void SetAttackingBehavior(IAttackingBehavior attackingBehavior)
        {
            if (attackingBehavior == null) throw new ArgumentNullException("attackingBehavior");
            this._attackingBehavior = attackingBehavior;
        }
        public void SetBlockingBehavior(IBlockingBehavior blockingBehavior)
        {
            if (blockingBehavior == null) throw new ArgumentNullException("blockingBehavior");
            this._blockingBehavior = blockingBehavior;
        }
        public void SetTappingBehavior(ITappingBehavior tappingBehavior)
        {
            this._tappingBehavior = tappingBehavior;
        }
       
        public void PerformAttack()
        {
            if(_attackingBehavior == null)throw new ArgumentException("Attacking behavior is null");
            _attackingBehavior.Attack();
        }
        public void PerformBlock()
        {
            if (_attackingBehavior == null) throw new ArgumentException("Blocking behavior is null");

            _blockingBehavior.Block();
        }
        public void PerformTap()
        {
            if (_attackingBehavior == null) throw new ArgumentException("Tapping behavior is null");
            _tappingBehavior.Tap();
        }
    }
}
